#include "getfilename.h"

int createsock(void){
    int sfd = socket(AF_INET, SOCK_STREAM, 0);
    if(sfd < 0)
    {
        perror("socket create error");
        _exit(1);
    }
    struct sockaddr_in serveraddr;

    serveraddr.sin_addr.s_addr = INADDR_ANY;
    serveraddr.sin_family = AF_INET;
    serveraddr.sin_port = htons(PORT);

    bind(sfd, (struct sockaddr *)&serveraddr, sizeof(serveraddr));

    fcntl(sfd, F_SETFD, fcntl(sfd, F_GETFD) | O_NONBLOCK);
    listen(sfd, 20);
    return sfd;
}
